﻿<#include "include/_meta.html">
<title>帐户列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 管理员管理 <span class="c-gray en">&gt;</span> 管理员列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="text-c">车牌号码：		
		<input type="text" class="carid" style="width:250px" placeholder="" id="carid" name="carid">
		开始时间：
		<input type="text" class="startTime" style="width:250px" placeholder="" id="startTime" name="startTime" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>
		截止时间：
		<input type="text" class="endTime" style="width:250px" placeholder="" id="endTime" name="endTime" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>
		<button type="submit" class="btn btn-success" id="searchUsers" name="" ><i class="Hui-iconfont">&#xe665;</i> 查询</button>
	</div>
	<table id="journalCarTable" style="" class="table table-border table-bordered table-bg table-hover" border="1">
		<thead>			
			<tr class="text-c">				
				<th width="220">收入科目</th>
				<th width="220">记录次数</th>
				<th width="220">记录金额</th>
			</tr>
			<tr class="text-c">				
				<td width="220">${projectCar}</td>
				<td width="220">${orderCount}</td>
				<td width="220">${orderPriceAll}</td>
			</tr>
		</thead>
		<tbody>
		</tbody>
	</table>
</div>
<div class="page-container">	
	<table id="CountCarTable" style="" class="table table-border table-bordered table-bg table-hover" border="1">
		<thead>			
			<tr class="text-c">				
				<th width="220">支出科目</th>
				<th width="220">记录次数</th>
				<th width="220">记录金额</th>
			</tr>
			<tr class="text-c">				
				<td width="220">${insurance}</td>
				<td width="220">0</td>
				<td width="220">0</td>
			</tr>
			<tr class="text-c">				
				<td width="220">${maintain}</td>
				<td width="220">0</td>
				<td width="220">0</td>
			</tr>
			<tr class="text-c">				
				<td width="220">${yearcheck}</td>
				<td width="220">0</td>
				<td width="220">0</td>
			</tr>
			<tr class="text-c">				
				<td width="220">${repair}</td>
				<td width="220">0</td>
				<td width="220">0</td>
			</tr>
			<tr class="text-c">				
				<td width="220">${ownerMoney}</td>
				<td width="220">0</td>
				<td width="220">0</td>
			</tr>
			<tr class="text-c">				
				<td width="220">${returnCash}</td>
				<td width="220">0</td>
				<td width="220">0</td>
			</tr>
		</thead>
		<tbody>
		</tbody>
	</table>
</div>
<#include "include/_footer.html">

<script type="text/javascript">

$(function(){

    initTable();

});


var initTable = function(){

$('#accountListTable').dataTable( {
    	"processing": false,
      	"serverSide": true,
      	"bSort": false,
      	"bFilter":false,
      	"bLengthChange":false,
      	"iDisplayLength":10,
      	"bRetrieve":true,
      	"ajax": {
            "url": "/getAccountList",
           	"data":function(d){
		        d.username = $('#username').val();
		        d.personid = $('#personid').val();
		        d.mobile = $('#mobile').val();
		    },
            "type": "get"
        },
        "columns": [       
            { "data": "" },
           // { "data": "uid" },
            { "data": "username" },
            { "data": "nickname" },
            { "data": "mobile" },
            { "data": "personid" },
            { "data": "userstate" },
            { "data": "deptcode" },
            { "data": "addtime" },
            { "data": "" }
      	],
      	"columnDefs": [
	        {
		          "targets": [0],
		          "data": "uid",
		          "render": function(data, type, full) {
		            return "<input type='checkbox' value=" +full.uid + " name='useritem'>";		           
		          }
	        },
	        {
		          "targets": [8],
		          "data": "uid",
		          "render": function(data, type, full) {		          	  
		          	   var action_userstate;
		          		if(full.userstate == '1'){
		          	       action_userstate = "<a style='text-decoration:none' onClick=\"admin_stop(this,'"+full.uid+"')\" href=\"javascript:;\" title=\"停用\"><i class=\"Hui-iconfont\">&#xe631;</i></a>";
		          		}else{
		          			action_userstate = "<a style='text-decoration:none' onClick=\"admin_start(this,'"+full.uid+"')\" href=\"javascript:;\" title=\"启用\"><i class=\"Hui-iconfont\">&#xe615;</i></a>";
		          		}		          			
		          		var action_edit = "<a title=\"编辑\" href=\"javascript:;\" onclick=\"account_edit('管理员编辑','/accountsedit?uid="+full.uid+"','2','800','500')\" class=\"ml-5\" style=\"text-decoration:none\">编辑</a>";
		          		var action_del  = "<a title=\"删除\" href=\"javascript:;\" onclick=\"account_del(this,'"+full.uid+"')\" class=\"ml-5\" style=\"text-decoration:none\">删除</a>";
		               return action_userstate+" "+action_edit+" "+action_del;
		          }
	        }	        
      	],
      	"fnRowCallback" : function(nRow, aData, iDisplayIndex) { 
      					                    
                        return "";  
         },
	    "fnDrawCallback": function(oSettings) {
		      //获取后台方式 直接可以拿到json 之后进行处理
		      var json=jQuery.parseJSON(oSettings.jqXHR.responseText);  
		      $("#pageTotal").html(json.recordsTotal);
	    }
  
      	
    });

}


$("#searchUsers").click(function() {    	
        $("#accountListTable").dataTable().fnClearTable();
        initTable();
});



var datadel = function(){
	
	//判断选择项是否为空
	var checkedNum = $("input[name='useritem']:checked").length;
	if(checkedNum==0){
		layer.msg('请选中要删除的列表项!',{icon: 5,time:1000});
		return;
	}
	//获取选择项的值
	var checkedVal = "";
	$("input[name='useritem']:checked").each(function(){  
		checkedVal+=$(this).val()+",";  
	});
	
	var itemsTipStr = "这条记录";
	if(checkedNum>1){
		itemsTipStr = "这些选项";
	}
	
	layer.confirm('确认要删除'+itemsTipStr+'吗？',function(){
	
		//此处请求后台程序，下方是成功后的前台处理……
		$.ajax({
		   type: "POST",
		   url: "/detAccounts",
		   data: "usersid="+checkedVal,
		   success: function(msg){
		   		   
				layer.msg('已删除!',{icon: 5,time:1000});
				
				$("#userListTable").dataTable().fnClearTable();
		        initTable();
		   }
		});
		

        
	});
	
	
}


/*
	参数解释：
	title	标题
	url		请求的url
	id		需要操作的数据id
	w		弹出层宽度（缺省调默认值）
	h		弹出层高度（缺省调默认值）
*/
/*管理员-增加*/
function account_add(title,url,w,h){
	layer_show(title,url,w,h);
}
/*管理员-删除*/
function account_del(obj,uid){
	layer.confirm('确认要删除吗？',function(index){
		//此处请求后台程序，下方是成功后的前台处理……
		
		
		$.ajax({
		   type: "POST",
		   url: "/accountsdelete",
		   data: "uid="+uid,
		   success: function(msg){
		       	$("#userListTable").dataTable().fnClearTable();
        		initTable();
		   }
		});
		
		
		$(obj).parents("tr").remove();
		layer.msg('已删除!',{icon:1,time:1000});
	});
}



/*管理员-编辑*/
function account_edit(title,url,uid,w,h){
	layer_show(title,url,w,h);
}
/*管理员-停用*/
function admin_stop(obj,uid){
	layer.confirm('确认要停用吗？',function(index){
		//此处请求后台程序，下方是成功后的前台处理……
		
		$.ajax({
		   type: "POST",
		   url: "/setAccountState",
		   data: "uid="+uid+"&userstate=0",
		   success: function(msg){
		       	$("#accountListTable").dataTable().fnClearTable();
        		initTable();
		   }
		});
		
		$(obj).parents("tr").find(".td-manage").prepend('<a onClick="admin_start(this,id)" href="javascript:;" title="启用" style="text-decoration:none"><i class="Hui-iconfont">&#xe615;</i></a>');
		$(obj).parents("tr").find(".td-status").html('<span class="label label-default radius">已禁用</span>');
		$(obj).remove();
		layer.msg('已停用!',{icon: 5,time:1000});
	});
}

/*管理员-启用*/
function admin_start(obj,uid){
	layer.confirm('确认要启用吗？',function(index){
			
		
		$.ajax({
		   type: "POST",
		   url: "/setAccountState",
		   data: "uid="+uid+"&userstate=1",
		   success: function(msg){
		       	$("#accountListTable").dataTable().fnClearTable();
        		initTable();
		   }
		});
		//$(obj).parents("tr").find(".td-manage").prepend('<a onClick="admin_stop(this,id)" href="javascript:;" title="停用" style="text-decoration:none"><i class="Hui-iconfont">&#xe631;</i></a>');
		//$(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
		//$(obj).remove();
		layer.msg('已启用!', {icon: 6,time:1000});
	});
}
</script>
</body>
</html>